// Copyright (c) 2025, yuxinyong and contributors
// For license information, please see license.txt

frappe.ui.form.on("Shoe Construction", {
    copy_field_to_quick_entry(frm){
	    let outsole_field = frm.get_docfield("outsole");
		outsole_field.get_route_options_for_new_doc = function(row) {		
            return {
                "last": frm.doc.last,                
            }        
		}        
	    let heel_field = frm.get_docfield("heel");
		heel_field.get_route_options_for_new_doc = function(row) {		
            return {
                "last": frm.doc.last,
                
            }        
		}        
	    let platform_field = frm.get_docfield("platform");
		platform_field.get_route_options_for_new_doc = function(row) {		
            return {
                "last": frm.doc.last,                
            }        
		}        
    },
    setup(frm) {
        frm.trigger("copy_field_to_quick_entry");
    },
	refresh(frm) {
        frm.trigger("copy_field_to_quick_entry");
	},
    // new_outsole(frm){       
    //     frm.events["create_item"](frm, "outsole")
    // }, 
    // new_heel(frm){       
    //     frm.events["create_item"](frm, "heel")
    // }, 
    // new_platform(frm){       
    //     frm.events["create_item"](frm, "platform")
    // }, 
    // create_item(frm, field){
    //     frm.call({
    //         method: "create_item",
    //         args: {
    //             field: field
    //         },
    //         doc: frm.doc,
    //         //btn: frm.page.btn_primary,
    //     }).then((r) => {
    //         if (r.message) {
    //             frm.set_value(field, r.message);
    //             frm.doc.__unsaved = true
    //         }
    //     });	
    // }
});
